fix: switch keychain to Data Protection to eliminate auth prompts#328
fix: switch keychain to Data Protection to eliminate auth prompts#328
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCentralizes Keychain access into a new KeychainHelper, updates storage classes to delegate keychain operations to it, adds a startup migration call to move legacy items into Data Protection-backed keychain storage, and adds tests and changelog entries documenting the change. Changes
Sequence Diagram(s)sequenceDiagram
participant App as App Startup (AppDelegate)
participant Helper as KeychainHelper
participant Legacy as Legacy Keychain
participant DPKeychain as Data Protection Keychain
App->>Helper: migrateFromLegacyKeychainIfNeeded()
Helper->>Legacy: Query legacy items
Legacy-->>Helper: Return items
loop per legacy item
Helper->>DPKeychain: Save item (kSecUseDataProtectionKeychain)
DPKeychain-->>Helper: Success / Error
alt Success
Helper->>Legacy: Delete legacy item
Legacy-->>Helper: Deleted
end
Helper->>Helper: Log progress
end
Helper->>Helper: Set migration flag in UserDefaults
Helper-->>App: Migration complete
sequenceDiagram
participant Storage as Storage class (AIKeyStorage / ConnectionStorage / LicenseStorage)
participant Helper as KeychainHelper (singleton)
participant DPKeychain as Data Protection Keychain
rect rgba(100,150,200,0.5)
Storage->>Helper: saveString(value, forKey:)
Helper->>DPKeychain: Save item with Data Protection
DPKeychain-->>Helper: Success / Error
Helper-->>Storage: Bool / result
end
rect rgba(150,200,100,0.5)
Storage->>Helper: loadString(forKey:)
Helper->>DPKeychain: Query item with Data Protection flag
DPKeychain-->>Helper: Data / not found
Helper-->>Storage: String? result
end
rect rgba(200,150,100,0.5)
Storage->>Helper: delete(key:)
Helper->>DPKeychain: Delete item
DPKeychain-->>Helper: Success / not found
Helper-->>Storage: Void
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
Summary
KeychainHelperusing the Data Protection keychain (kSecUseDataProtectionKeychain: true) per Apple TN3137, eliminating per-item ACL prompts that appeared on every table openkSecAttrAccessibletoAfterFirstUnlock(wasWhenUnlockedThisDeviceOnly), restoring background reconnection while screen is lockedConnectionStorage,AIKeyStorage, andLicenseStorageto delegate all keychain operations toKeychainHelperCloses #326
Test plan
AfterFirstUnlock)KeychainHelperTestsandKeychainAccessControlTestsSummary by CodeRabbit
New Features
Bug Fixes
Tests
Chores